#include "lineconnectorelement.h"
#include "../sagevis.h"
#include "../VisBaseClasses/visbaseelement.h"
#include "../VisBaseClasses/visbasewidget.h"


LineConnectorElement::LineConnectorElement(QPointer<VisBaseElement> e1, QPointer<VisBaseElement> e2, QPointer<SageVis> sageVisPointer, QPointer<VisBaseWidget> parentWidget, QGraphicsItem *parent ) :
    VisBaseElement( sageVisPointer, parentWidget, parent ), elt1(e1), elt2(e2)
{
    super::setPos(0.0, 0.0);
    super::setGeometry(0.0, 0.0, 0.0, 0.0);
    setZValue(-10.0);
}

void LineConnectorElement::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
    //----prevent compiler warnings by declaring what I am not using---
    Q_UNUSED(widget);
    Q_UNUSED(option);

    //----SET COLOR----
    //default color light gray, white when hovering
    QColor c(200.0, 200.0, 200.0, 255.0);
    QPen pen;
    pen.setWidth(1.0);
    if( hovering )
    {
        c.setRgb(255.0, 255.0, 255.0);
        pen.setWidth(2.0);
    }
    pen.setColor(c);

    //----DRAW----
    painter->setBrush( c );
    painter->setPen( pen );
    painter->drawLine(elt1->getLineConnectionPoint(), elt2->getLineConnectionPoint() );

}
